package com.dyh.quickdemo.future;

import org.junit.jupiter.api.Test;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/*
@Author=Joey Wheeler
@Date=2021/4/21 17:54
*/
public class TestFuture {
    @Test
    public void test() throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        Future<String> future = executorService.submit(()->{
            if (1==1)
                throw new RuntimeException();
            return "1";
        });

        String res = future.get();

        System.out.println();
        //        System.out.println(future.get());
    }
}
